package com.bw.a2209clubshop.ui.mine

import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.a2209clubshop.R
import com.bw.a2209clubshop.base.BaseFragment
import com.bw.a2209clubshop.databinding.FragmentMineBinding
import com.bw.a2209clubshop.mmkv.AuthMMKV
import com.bw.a2209clubshop.ui.login.LoginActivity
import com.bw.a2209clubshop.ui.main.viewModel.MainViewModel
import com.bw.a2209clubshop.utils.Router
import com.bw.a2209clubshop.utils.ToastUtils
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject

@AndroidEntryPoint
class MineFragment @Inject constructor() : BaseFragment<MainViewModel, FragmentMineBinding>(){
    override val mLayoutResId: Int
        get() = R.layout.fragment_mine
    private val mViewModel: MainViewModel by activityViewModels()
    override fun initView() {
        super.initView()
        initShowView()
    }
    private fun initShowView() {
//        initStatusBar()
        if (AuthMMKV.token.isEmpty()) {
//            onNotLogin()
            ARouter.getInstance().build(Router.Ui.LoginActivity).withTransition(R.anim.bottom_in, R.anim.fab_out).navigation()
        } else {
            //已经登录
            ToastUtils.showShort(requireActivity(),"Token---"+AuthMMKV.token)
            mBinding.tvMine.setOnClickListener{_->
                startActivity(Intent(requireActivity(),LoginActivity::class.java))
//                ARouter.getInstance().build(Router.Ui.LoginActivity).withTransition(R.anim.bottom_in, R.anim.fab_out).navigation()
            }
//            onLogin()
        }
    }

}